﻿package com.victim.snake.util {
	import flash.display.Loader;
	import flash.events.Event;
	import flash.net.URLRequest;
	import flash.events.IOErrorEvent;
	import flash.text.TextField;
	import com.victim.snake.user.User;
	import com.victim.snake.user.ProcessMsg;
	
	
	//加载外部资源类
	public class Loader extends flash.display.Loader {
		
		//构造函数
		public function Loader(url:String,eventFunction:Function) {
			this.contentLoaderInfo.addEventListener(Event.COMPLETE,eventFunction);
			this.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,ioError);

			this.load(new URLRequest(url));
		}
		
		public function ioError(ever:IOErrorEvent){
			ProcessMsg.errorText.text="资源加载错误";
			ProcessMsg.errorText.x=100;
			ProcessMsg.errorText.y=100;
			
			//显示错误信息
			User.getStage().addChild(ProcessMsg.errorText);
		}
	}
	
}
